var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
}),
o.rewardType = void 0;
var r, s = t("GlobalUserData"),
l = t("Util"),
c = t("AssemblyItem"),
d = t("CarConstant"),
h = t("WXSDK"),
p = cc._decorator,
u = p.ccclass,
f = p.property; (function(t) {
    t[t.commonBox = 0] = "commonBox",
    t[t.epicBox = 1] = "epicBox",
    t[t.legendBox = 2] = "legendBox",
    t[t.item = 3] = "item",
    t[t.gold = 4] = "gold",
    t[t.diamond = 5] = "diamond",
    t[t.vit = 6] = "vit"
})(r = o.rewardType || (o.rewardType = {}));
var m = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.icon_box_common = null,
        e.icon_box_epic = null,
        e.icon_box_legend = null,
        e.icon_gold = null,
        e.icon_diamond = null,
        e.icon_vit = null,
        e.frame_common = null,
        e.frame_epic = null,
        e.frame_legend = null,
        e.frame_box = null,
        e.frame_item = null,
        e.frame_bonus = null,
        e.frameContent = null,
        e.pfb_assemblyItem = null,
        e.btnGet = null,
        e.TTBtnGet = null,
        e.btnVideo = null,
        e.call = null,
        e.specialCallBack = null,
        e.mistakeBannerTimer = null,
        e.isShowMistakeBanner = !0,
        e.isMistakeBtn = !1,
        e.assemblyItem = null,
        e.isBtnClickOnce = !1,
        e
    }
    return n(e, t),
    e.prototype.showMistakeBtn = function() {
        var t = this;
        s.default.bAuditMode || (this.btnGet.active = !1, this.btnVideo.active = !0, setTimeout(function() {
            t.TTBtnGet.active = !0
        },
        0), this.isMistakeBtn = !0)
    },
    e.prototype.onEnable = function() {
        l.Util.hideSingleCustomAd(),
        l.Util.show_VerticalCustomAd(!1),
        l.Util.show_VerticalCustomAd(!0)
    },
    e.prototype.start = function() {
        var t = this;
        l.Util.isBannerSwitchOn() ? (l.Util.hideBanner(), this.node.getChildByName("base").y = -30, setTimeout(function() {
            h.default.getIntance().show_majia_banner(function() {
                t.node.getChildByName("base").y = 70
            })
        },
        1e3 * s.default.majiaDelay)) : l.Util.showBanner()
    },
    e.prototype.onDisable = function() {
        h.default.getIntance().hide_majia_banner(),
        l.Util.hideBanner(),
        l.Util.hide_VerticalCustomAd(!1),
        l.Util.hide_VerticalCustomAd(!0)
    },
    e.prototype.initView = function(t, e, o, i, n) {
        var a = this;
        void 0 === o && (o = !0),
        void 0 === i && (i = !1),
        i && this.showMistakeBtn(),
        this.isShowMistakeBanner = o,
        !s.default.bAuditMode && o && s.default.isShowMistakeBanner && (this.mistakeBannerTimer = setTimeout(function() {
            l.Util.showMistakeBanner(function() {
                a.mistakeBannerTimer = setTimeout(function() {
                    l.Util.hideMistakeBanner(),
                    l.Util.showBanner()
                },
                2e3)
            },
            function() {
                l.Util.showBanner()
            })
        },
        1e3)),
        this.call = e,
        n && (this.specialCallBack = n);
        for (var c = 0,
        d = t; c < d.length; c++) {
            var h = d[c],
            p = null;
            switch (h.type) {
                case r.item:
                    p = cc.instantiate(this.frame_item),
                this.frameContent.addChild(p),
                p.getComponent(cc.Sprite).spriteFrame = this.frame_common,
                this.onUpdateItem(p, h.itemData),
                p.children[1].getComponent(cc.Label).string = this.getItemName(h.itemData);
                break;
                case r.diamond:
                    p = cc.instantiate(this.frame_bonus),
                this.frameContent.addChild(p),
                p.getComponent(cc.Sprite).spriteFrame = this.frame_common,
                p.children[0].getComponent(cc.Sprite).spriteFrame = this.icon_diamond,
                p.children[1].getComponent(cc.Label).string = h.num.toString();
                break;
                case r.gold:
                    p = cc.instantiate(this.frame_bonus),
                this.frameContent.addChild(p),
                p.getComponent(cc.Sprite).spriteFrame = this.frame_common,
                p.children[0].getComponent(cc.Sprite).spriteFrame = this.icon_gold,
                p.children[1].getComponent(cc.Label).string = h.num.toString();
                break;
                case r.vit:
                    p = cc.instantiate(this.frame_bonus),
                this.frameContent.addChild(p),
                p.getComponent(cc.Sprite).spriteFrame = this.frame_common,
                p.children[0].getComponent(cc.Sprite).spriteFrame = this.icon_vit,
                p.children[0].scale = 2,
                p.children[1].getComponent(cc.Label).string = h.num.toString();
                break;
                case r.commonBox:
                    p = cc.instantiate(this.frame_box),
                this.frameContent.addChild(p),
                p.getComponent(cc.Sprite).spriteFrame = this.frame_common,
                p.children[0].getComponent(cc.Sprite).spriteFrame = this.icon_box_common,
                p.children[0].scale = .8,
                p.children[1].getComponent(cc.Label).string = "普通宝箱";
                break;
                case r.epicBox:
                    p = cc.instantiate(this.frame_box),
                this.frameContent.addChild(p),
                p.getComponent(cc.Sprite).spriteFrame = this.frame_epic,
                p.children[0].getComponent(cc.Sprite).spriteFrame = this.icon_box_epic,
                p.children[0].scale = .8,
                p.children[1].getComponent(cc.Label).string = "稀有宝箱";
                break;
                case r.legendBox:
                    p = cc.instantiate(this.frame_box),
                this.frameContent.addChild(p),
                p.getComponent(cc.Sprite).spriteFrame = this.frame_legend,
                p.children[0].getComponent(cc.Sprite).spriteFrame = this.icon_box_legend,
                p.children[0].scale = .8,
                p.children[1].getComponent(cc.Label).string = "传说宝箱";
            }
        }
    },
    e.prototype.onUpdateItem = function(t, e) {
        if (!this.assemblyItem) {
            var o = cc.instantiate(this.pfb_assemblyItem);
            o.position = cc.v3(0, 20, 0),
            o.scale = .8,
            t.addChild(o),
            this.assemblyItem = o
        }
        this.assemblyItem.getComponent(c.AssemblyItem).updateItem(null, !0, 0, e, !1, c.Assembly_Type.Attribute)
    },
    e.prototype.onBtnClose = function() {
        this.isBtnClickOnce || s.default.bAuditMode || !this.isShowMistakeBanner || !s.default.isShowMistakeBanner ? (this.isBtnClickOnce = !1, clearTimeout(this.mistakeBannerTimer), l.Util.hideMistakeBanner(), l.Util.hideBanner(), this.node.destroy(), this.call && this.call()) : this.isBtnClickOnce = !0
    },
    e.prototype.onBtnVideo = function() {
        var t = this;
        l.Util.showRewardVideo(function() {
            l.Util.hideBanner(),
            t.node.destroy(),
            t.specialCallBack && t.specialCallBack()
        })
    },
    e.prototype.getItemName = function(t) {
        return l.Util.getCarItemData,
        t.type == d.Basics_Items_Type.body ? d.getBodyData(t.id).name: t.type == d.Basics_Items_Type.wheel ? d.getWheelData(t.id).name: t.type == d.Basics_Items_Type.tools ? d.getToolsData(t.id).name: t.type == d.Basics_Items_Type.weapon ? d.getWeaponData(t.id).name: void 0
    },
    a([f(cc.SpriteFrame)], e.prototype, "icon_box_common", void 0),
    a([f(cc.SpriteFrame)], e.prototype, "icon_box_epic", void 0),
    a([f(cc.SpriteFrame)], e.prototype, "icon_box_legend", void 0),
    a([f(cc.SpriteFrame)], e.prototype, "icon_gold", void 0),
    a([f(cc.SpriteFrame)], e.prototype, "icon_diamond", void 0),
    a([f(cc.SpriteFrame)], e.prototype, "icon_vit", void 0),
    a([f(cc.SpriteFrame)], e.prototype, "frame_common", void 0),
    a([f(cc.SpriteFrame)], e.prototype, "frame_epic", void 0),
    a([f(cc.SpriteFrame)], e.prototype, "frame_legend", void 0),
    a([f(cc.Prefab)], e.prototype, "frame_box", void 0),
    a([f(cc.Prefab)], e.prototype, "frame_item", void 0),
    a([f(cc.Prefab)], e.prototype, "frame_bonus", void 0),
    a([f(cc.Node)], e.prototype, "frameContent", void 0),
    a([f(cc.Prefab)], e.prototype, "pfb_assemblyItem", void 0),
    a([f(cc.Node)], e.prototype, "btnGet", void 0),
    a([f(cc.Node)], e.prototype, "TTBtnGet", void 0),
    a([f(cc.Node)], e.prototype, "btnVideo", void 0),
    a([u], e)
} (cc.Component);
o.default = m